/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sda.levelup.threads;

/**
 *
 * @author user
 */
public class SecondThread implements Runnable
{

    private Storage storage;
    boolean a = true;

    public SecondThread(Storage storage)
    {
        this.storage = storage;
    }

    @Override
    public void run()
    {
        while (a)
        {
            try
            {
                System.err.println("Number of elements: " + storage.getSize());
                Thread.sleep(2000);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
    }
    public void turnOff(){
        a=false;
    }

}
